<template>
	<view class="box">
		<view class="hezi">
			<view class="toux">
				<span>原始密码</span>
				<input type="text" v-model="params.oldPassword"  placeholder="请输入原始密码" />
			</view>
			<view class="toux" style="border-bottom: none;">
				<span>新密码</span>
				<input type="text" v-model="params.newPassword" placeholder="请输入新密码" />
			</view>
			<view class="toux" style="border-bottom: none;">
				<span>确认密码</span>
				<input type="text" v-model="params.newPasswords"  placeholder="请再次输入新密码" />
			</view>
		</view>
		<button @click="xiu">保存</button>
	</view>
</template>

<script>
	import {
		setPassword
	} from '@/common/http.api.js';
	export default {
		data() {
			return {
				params:{
					oldPassword:'',
					newPassword:'',
					newPasswords:''
				}
			}
		},
		methods: {
			xiu() {
				uni.request({
					url:`https://calculate.weitukongjian.com/calculate-api/system/user/profile/updatePwd?oldPassword=${this.params.oldPassword}&newPassword=${this.params.newPassword}`,
					method:'PUT',
					header: {
						'Authorization': 'Bearer ' +  uni.getStorageSync('token'),
					},
					success: (res) => {
						if(res.data.code == 200){
							uni.showToast({
								title: '修改成功重新登陆',
								duration:2000,
								mask:false,
								icon:"none"
							})
							setTimeout(()=>{
								uni.reLaunch({
									url:'/pages/index/login'
								})
							},1500)
						}else{
							uni.showToast({
								title: res.data.msg,
								duration:2000,
								mask:false,
								icon:"none"
							})
						}
							
					},
					fail: (err) => {
						uni.showToast({
							title: err.data.msg,
							duration:2000,
							mask:false,
							icon:"none"
						})
					},
					// complete:(es)=>{
					// 	console.log('1111111112222');
					// 	uni.showToast({
					// 		title: es.data.msg,
					// 		duration:2000,
					// 		mask:false,
					// 		icon:"none"
					// 	})
					// }
					
				})
			}
		},
		mounted() {

		},
		onLoad() {}
	}
</script>

<style lang="scss" scoped>
	.box {
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	button {
		width: 695rpx;
		height: 80rpx;
		background: #065CF7;
		border-radius: 40rpx;
		font-family: PingFang SC;
		font-weight: bold;
		font-size: 28rpx;
		color: #FFFFFF;
		margin-top: 60rpx;
		line-height: 80rpx;
	}

	.toux {
		display: flex;
		align-items: center;
		justify-content: space-between;
		border-bottom: 1px #EEEEEE solid;
		height: 120rpx;

		input {
			width: 75%;
		}

		span {
			font-family: PingFang SC;
			font-weight: 500;
			font-size: 28rpx;
			color: #333333;
		}

		view {
			display: flex;
			align-items: center;
		}

		image {
			width: 98.1rpx;
			height: 98.1rpx;
			border-radius: 50%;
		}
	}

	.hezi {
		width: 660rpx;
		background: #FFFFFF;
		border-radius: 14rpx;
		margin-top: 20rpx;
		padding: 20rpx;
	}
</style>